-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update google_sql_database
and google_sql_user
to not do Read actions when instance is not active
#11866
Update google_sql_database
and google_sql_user
to not do Read actions when instance is not active
#11866
Conversation
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @SarahFrench, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 97 Click here to see the affected service packages
Action takenFound 7 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jharshika, thanks for pivoting from your previous approach to solve this issue!
I believe I understand the problem and the solution in this PR is option 5 described in the linked GitHub issue:
Option 5: Check the activation_policy before refreshing
Given the existing tests all pass here it looks like this change doesn't impact provisioning google_sql_* resources. However it looks like there are no tests covering the scenario that triggers the API errors in the linked GitHub issue.
Could you please add an acceptance test that would have triggered the API error prior to your PR? I'm imagining an update test where the first step provisions a google_sql_database_instance with activation_policy="ALWAYS", a google_sql_database, and a google_sql_user resource, and then in a second step activation_policy is updated to "NEVER"? There might be a better approach that better resembles how a user might trigger this API error, but either way I think we should add a test to prove the issue is solved.
Hi @SarahFrench Added the tests and verified it locally as well to verify the functionality. |
mmv1/third_party/terraform/services/sql/resource_sql_user_test.go
Outdated
Show resolved
Hide resolved
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 99 Click here to see the affected service packages
Tests were added that are skipped in VCR:
View the build log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test!
I ran the new code and tests from this PR in our test environment and I found a few things that needed a fix. However they're mostly to do with how the testing framework works instead of the config, so I figured I'd suggest the changes in a review. Also, I confirmed that the test fails when it's run using the code from main.
I hope it's ok but I'll go ahead and merge the suggested changes, run the tests, and we should be in a position to merge.
mmv1/third_party/terraform/services/sql/resource_sql_user_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/sql/resource_sql_user_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/sql/resource_sql_user_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/sql/resource_sql_user_test.go
Outdated
Show resolved
Hide resolved
This includes: - Update to allow the test's post-test destroy code to delete resources without error - Removes checks that tried to read the user's data and triggered the "Error 400: Invalid request: Invalid request since instance is not running., invalid" API error
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 99 Click here to see the affected service packages
Tests were added that are skipped in VCR:
View the build log |
For future reference by maintainers, here's a build running that acc tess with the latest code: BUILD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the TestAccSqlUser_instanceWithActivationPolicy test is passing! 🎉
Just to make sure nothing is overlooked, could you add a similar test for the database resource?
Thanks @SarahFrench for the suggested code changes. Updated the unit test for both user and database. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 100 Click here to see the affected service packages
🔴 Tests were added that are skipped in VCR:
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
I'm just running the skipped test again to confirm everything's ok. Assuming it passes I'll approve and merge. Thank you for the additional test! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test mentioned here passed, so approving & merging. Thanks for such a smooth PR process!
Final note on this PR for any future reference: I've set the release note to
This PR doesn't prevent create/update/delete actions as the API error is useful in those cases. We need to skip Read when the instance isn't available, as the instance isn't queryable then. There may be Terraform configurations that are valid and contain a |
google_sql_database
and google_sql_user
to not do Read actions when instance is not active
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
…ions when instance is not active (GoogleCloudPlatform#11866) Co-authored-by: Sarah French <[email protected]>
This pull request addresses issue hashicorp/terraform-provider-google#7810. If the activation policy is not ALWAYS i.e. the instance is not active, return from the get resource method of "user" and "database". In the API layer if the activation policy is not set the ALWAYS then get resource will throw an error. To avoid breaking
terraform plan
, updating the getter method to avoid the error during refresh.With these changes,
terraform plan
andterraform apply
will succeed. If the customer try to update/delete the resource, it will still throw exception as it is not supported for inactive resources.Release Note Template for Downstream PRs (will be copied)